home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / dns / set.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  6.0 KB  |  224 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4.  
  5. class Set(object):
  6.     __slots__ = [
  7.         'items']
  8.     
  9.     def __init__(self, items = None):
  10.         self.items = []
  11.         if items is not None:
  12.             for item in items:
  13.                 self.add(item)
  14.             
  15.         
  16.  
  17.     
  18.     def __repr__(self):
  19.         return 'dns.simpleset.Set(%s)' % repr(self.items)
  20.  
  21.     
  22.     def add(self, item):
  23.         if item not in self.items:
  24.             self.items.append(item)
  25.         
  26.  
  27.     
  28.     def remove(self, item):
  29.         self.items.remove(item)
  30.  
  31.     
  32.     def discard(self, item):
  33.         
  34.         try:
  35.             self.items.remove(item)
  36.         except ValueError:
  37.             pass
  38.  
  39.  
  40.     
  41.     def _clone(self):
  42.         cls = self.__class__
  43.         obj = cls.__new__(cls)
  44.         obj.items = list(self.items)
  45.         return obj
  46.  
  47.     
  48.     def __copy__(self):
  49.         return self._clone()
  50.  
  51.     
  52.     def copy(self):
  53.         return self._clone()
  54.  
  55.     
  56.     def union_update(self, other):
  57.         if not isinstance(other, Set):
  58.             raise ValueError, 'other must be a Set instance'
  59.         
  60.         if self is other:
  61.             return None
  62.         
  63.         for item in other.items:
  64.             self.add(item)
  65.         
  66.  
  67.     
  68.     def intersection_update(self, other):
  69.         if not isinstance(other, Set):
  70.             raise ValueError, 'other must be a Set instance'
  71.         
  72.         if self is other:
  73.             return None
  74.         
  75.         for item in list(self.items):
  76.             if item not in other.items:
  77.                 self.items.remove(item)
  78.                 continue
  79.         
  80.  
  81.     
  82.     def difference_update(self, other):
  83.         if not isinstance(other, Set):
  84.             raise ValueError, 'other must be a Set instance'
  85.         
  86.         if self is other:
  87.             self.items = []
  88.         else:
  89.             for item in other.items:
  90.                 self.discard(item)
  91.             
  92.  
  93.     
  94.     def union(self, other):
  95.         obj = self._clone()
  96.         obj.union_update(other)
  97.         return obj
  98.  
  99.     
  100.     def intersection(self, other):
  101.         obj = self._clone()
  102.         obj.intersection_update(other)
  103.         return obj
  104.  
  105.     
  106.     def difference(self, other):
  107.         obj = self._clone()
  108.         obj.difference_update(other)
  109.         return obj
  110.  
  111.     
  112.     def __or__(self, other):
  113.         return self.union(other)
  114.  
  115.     
  116.     def __and__(self, other):
  117.         return self.intersection(other)
  118.  
  119.     
  120.     def __add__(self, other):
  121.         return self.union(other)
  122.  
  123.     
  124.     def __sub__(self, other):
  125.         return self.difference(other)
  126.  
  127.     
  128.     def __ior__(self, other):
  129.         self.union_update(other)
  130.         return self
  131.  
  132.     
  133.     def __iand__(self, other):
  134.         self.intersection_update(other)
  135.         return self
  136.  
  137.     
  138.     def __iadd__(self, other):
  139.         self.union_update(other)
  140.         return self
  141.  
  142.     
  143.     def __isub__(self, other):
  144.         self.difference_update(other)
  145.         return self
  146.  
  147.     
  148.     def update(self, other):
  149.         for item in other:
  150.             self.add(item)
  151.         
  152.  
  153.     
  154.     def clear(self):
  155.         self.items = []
  156.  
  157.     
  158.     def __eq__(self, other):
  159.         for item in self.items:
  160.             if item not in other.items:
  161.                 return False
  162.                 continue
  163.         
  164.         for item in other.items:
  165.             if item not in self.items:
  166.                 return False
  167.                 continue
  168.         
  169.         return True
  170.  
  171.     
  172.     def __ne__(self, other):
  173.         return not self.__eq__(other)
  174.  
  175.     
  176.     def __len__(self):
  177.         return len(self.items)
  178.  
  179.     
  180.     def __iter__(self):
  181.         return iter(self.items)
  182.  
  183.     
  184.     def __getitem__(self, i):
  185.         return self.items[i]
  186.  
  187.     
  188.     def __delitem__(self, i):
  189.         del self.items[i]
  190.  
  191.     
  192.     def __getslice__(self, i, j):
  193.         return self.items[i:j]
  194.  
  195.     
  196.     def __delslice__(self, i, j):
  197.         del self.items[i:j]
  198.  
  199.     
  200.     def issubset(self, other):
  201.         if not isinstance(other, Set):
  202.             raise ValueError, 'other must be a Set instance'
  203.         
  204.         for item in self.items:
  205.             if item not in other.items:
  206.                 return False
  207.                 continue
  208.         
  209.         return True
  210.  
  211.     
  212.     def issuperset(self, other):
  213.         if not isinstance(other, Set):
  214.             raise ValueError, 'other must be a Set instance'
  215.         
  216.         for item in other.items:
  217.             if item not in self.items:
  218.                 return False
  219.                 continue
  220.         
  221.         return True
  222.  
  223.  
  224.